<template>
  <div class="pageAll">
    <div class="loginForm">
      <div class="logTitle">欢迎！</div>
      <a-card title="登录" class="loginCard">
        <a-input class="inputArea" v-model:value="uAccount" placeholder="手机号/邮箱">
          <a-icon type="user" />
        </a-input>
        <a-input class="inputArea" type="password"  v-model:value="uPwd" placeholder="密码">
          <a-icon type="eye" />
        </a-input>
      </a-card>
      <a-button type="primary" class="btn" @click="loginIn" :loading="loading">
        <template #icon><LoginOutlined /></template>
        立即登录
      </a-button>
      <div class="opration-row">
<!--        <div class="forget-btn" @click="forgetPsw">忘记密码</div>-->
<!--        <div class="register-btn" @click="register">注册</div>-->
      </div>
    </div>
  </div>
</template>

<script>

import {LoginOutlined} from "@ant-design/icons-vue"
import {login} from "@/utils/api";

export default {
  name: 'login',
  components:{
    LoginOutlined
  },
  data(){
    return{
      uAccount:"",
      uPwd:"",
      loading:false
    }
  },
  mounted() {

  },
  methods:{
    /*
    * 忘记密码
    * */
    forgetPsw(){

    },
    /*注册*/
    register(){
      this.$router.push('/register')
    },
    /*
    * 登录
    * */
    loginIn(){

      if (this.uAccount.length == 0){
        this.$message.error("请输入账号");
        return
      }
      if (this.uPwd.length == 0){
        this.$message.error("请输入密码");
        return;
      }
      let param = {
        account: this.uAccount,
        password: this.uPwd
      }
      this.loading = true;
      login({
        method:'POST',
        data: param
      }).then(res => {
        this.loading = false;
        let data = res.data

        if (data.status == true) {
          this.$router.replace('/home')
          this.$message.success(data.msg)
        }else {
          this.$message.error(data.msg)
        }
      },fail => {
        this.loading = false;
      })

    }
  }
}
</script>

<style lang="scss" scoped>
.pageAll{
  width: 100vw;
  height:100vh;
  text-align: center;
  background: url('@/assets/loginBg.jpg') center center fixed no-repeat;
  background-size: cover;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-direction: column;
  font-weight: bold;
  font-size: 36px;
  -moz-user-select:none; /* Firefox私有属性 */
  -webkit-user-select:none; /* WebKit内核私有属性 */
  -ms-user-select:none; /* IE私有属性(IE10及以后) */
  -khtml-user-select:none; /* KHTML内核私有属性 */
  -o-user-select:none; /* Opera私有属性 */
  user-select:none; /* CSS3属性 */
}
.bottom-contain{
  display: flex;
  position: relative;
  bottom: 30px;
  left: 350px;
  font-size: 15px;
  color: darkgray;
  font-weight: 100;
}
.pageAll .loginForm{
  position: relative;
  left: 400px;
  margin-bottom: 20%;
}
.loginForm .logTitle{
  font-weight: bold;
  font-size: 36px;
  margin: 20px 8vw 20px 0;
}
.loginForm .loginCard{
  border-radius: 8px;
  width: 400px;
  margin: 20px 8vw 20px 0;
  /*background-color: #459BF0;*/
}
.loginCard .inputArea{
  margin: 10px 0;
}
.btn{
  width: 400px;
  margin: 20px 8vw 20px 0;
}
.opration-row{
  width: 400px;
  font-size: 12px;
  display: flex;
  flex-direction: row;
  .forget-btn{
    justify-items:left;
    margin-left: 5px;
    color: #adadad;
  }
  .register-btn{
    justify-self: flex-end;
    position:relative;
    left: 315px;
    color: #4e9ef0;
  }
}


</style>
